package com.swp.oa.sys.util;

import java.io.IOException;

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

public class MessageFilter implements Filter{

	@Override
	public void destroy() {
		
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response,
			FilterChain chain) throws IOException, ServletException {
		// 将请求转换成HttpServletRequest 请求
//		HttpServletRequest hrequest = (HttpServletRequest) request;
//		String requestUrl = hrequest.getRequestURL().toString();//得到请求的URL地址
//		 String requestUri = hrequest.getRequestURI();//得到请求的资源
//		 String queryString = hrequest.getQueryString();//得到请求的URL地址中附带的参数
//		 String method = hrequest.getMethod();//得到请求URL地址时使用的方法
//		 String pathInfo = hrequest.getPathInfo();
//		 System.out.println("requestUrl: " + requestUrl);
//		 System.out.println("requestUri: " + requestUri);
//		 System.out.println("queryString: " + queryString);
//		 System.out.println("method: " + method);
//		 System.out.println("pathInfo: " + pathInfo);
		 chain.doFilter(request, response);  //让目标资源执行，放行
	}

	@Override
	public void init(FilterConfig arg0) throws ServletException {
		
	}

}
